package com.a.lib_network.bean;

import com.google.gson.annotations.SerializedName;
import org.jetbrains.annotations.NotNull;

/**
 * 复用的接口返回格式
 */
public class HttpData<T> {

    @SerializedName("success")
    private boolean success;
    @SerializedName("msg")
    private String msg;
    @SerializedName("data")
    private T data;

    public boolean isSuccess() {
        return success;
    }

    public HttpData<T> setSuccess(boolean success) {
        this.success = success;
        return this;
    }

    public String getMsg() {
        return msg;
    }

    public HttpData<T> setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public HttpData() {
    }

    public HttpData(T data) {
        this.data = data;
    }

    public HttpData(Boolean success, String msg) {
        this.success = success;
        this.msg = msg;
    }

    public interface Result<T> {
        void onResult(HttpData<T> dataResult);
    }

    @NotNull
    @Override
    public String toString() {
        return "HttpData{" +
                "success=" + success +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }
}
